﻿using System;
using System.Runtime.Serialization;

namespace CapstoneProjectAEReader.Entities.Models
{
    [Serializable()]
    public class Bookmark : ISerializable
    {
        private int _bookmarkid;
        private int _bookid;
        private int _pagenumber;
        private string _description;
        private bool _isparentbookmark;
        private int _noc;
        private int _parentid;

        public Bookmark() { }
        public int Bookmarkid
        {
            get { return _bookmarkid; }
            set { _bookmarkid = value; }
        }

        public int Bookid
        {
            get { return _bookid; }
            set { _bookid = value; }
        }

        public int Pagenumber
        {
            get { return _pagenumber; }
            set { _pagenumber = value; }
        }

        public string Description
        {
            get { return _description; }
            set { _description = value; }
        }

        public bool Isparentbookmark
        {
            get { return _isparentbookmark; }
            set { _isparentbookmark = value; }
        }

        public int Noc
        {
            get { return _noc; }
            set { _noc = value; }
        }

        public int Parentid
        {
            get { return _parentid; }
            set { _parentid = value; }
        }

        // Serialize
        public Bookmark(SerializationInfo info, StreamingContext ctxt)
        {
            _bookmarkid = (int)info.GetValue("BookmarkID", typeof(int));
            _bookid = (int)info.GetValue("Bookid", typeof(int));
            _pagenumber = (int)info.GetValue("Pagenumber", typeof(int));
            _description = (string)info.GetValue("Description", typeof(string));
            _isparentbookmark = (bool)info.GetValue("Isparentbookmark", typeof(bool));
            _noc = (int)info.GetValue("Noc", typeof(int));
            _parentid = (int)info.GetValue("Parentid", typeof(int));
        }

        public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
        {
            info.AddValue("BookmarkID", _bookmarkid);
            info.AddValue("Bookid", _bookid);
            info.AddValue("Pagenumber", _pagenumber);
            info.AddValue("Description", _description);
            info.AddValue("Isparentbookmark", _isparentbookmark);
            info.AddValue("Noc", _noc);
            info.AddValue("Parentid", _parentid);
        }
    }
}
